<template>
    <div id="list">
        <h2 ref="h2"><svg class="icon"><use xlink:href="#icon-tixian2"></use></svg>提现列表</h2>
        <cube-scroll ref="scroll" :options="scroll_options" :style="{height:height+'px'}" @pulling-up="upLoad">
            <ul v-if="list.data.length > 0">
                <li v-for="item in list.data" :key="item.id">
                    <p>￥{{item.money}}</p>
                    <p class="doing" v-if="item.status == 0">提现中</p>
                    <p v-else-if="item.status == 1">提现成功</p>
                    <p v-else class="error">提现失败</p>
                    <p>{{item.time}}</p>
                </li>
            </ul>
            <empty margin-top="30%" v-else>暂无数据</empty>
        </cube-scroll>
    </div>
</template>

<script>
    import empty from "../../../../../../components/empty/Empty";
    export default {
        name: "cast-list",
        data(){
            return {
                height:0,
                scroll_options:{
                    scrollbar:true,
                    pullUpLoad:{
                        txt:{more:'上拉加载',noMore:'----我也是有底线的----'}
                    }
                },
                list:{
                    data:[],
                    limit:[0,15]
                },
                loading:false  //是否正在加载中
            }
        },
        components:{
          empty
        },
        created(){
            this.getList();
        },
        mounted() {
            this.height = document.documentElement.clientHeight - document.querySelector('#cash #header').getBoundingClientRect().height - this.$refs.h2.getBoundingClientRect().height;
        },
        methods:{
            /**
             * 获取列表
             */
            getList(){
                if(this.loading) return true;
                this.loading = true;
                this.$url('cash/getUserList',{
                    limit:this.list.limit
                })
                    .then((res)=>{
                        this.loading = false;
                        if(res.data.status == 'success'){
                            this.list.limit[0] += this.list.limit[1];
                            this.list.data.push(...res.data.data);
                            this.$refs.scroll.forceUpdate(true,true);
                        }else{
                            if(this.list.limit[0] === 0){
                                this.scroll_options.pullUpLoad = false;
                            }else{
                                this.$refs.scroll.forceUpdate(false,false);
                            }
                        }
                    });
            },
            /**
             * 上拉加载
             */
            upLoad(){
                this.getList();
            }
        }
    }
</script>

<style scoped lang="less" src="./castlist.less"></style>
